/**
 * Created by python on 19-1-14.
 */
/**
 * Created by python on 19-1-13.
 */
/**
 * Created by python on 19-1-11.
 */
/**
 * Created by python on 19-1-11.
 */
var vm = new Vue({
    el: '#app',
    // 声明Vue使用的模板变量语法
    delimiters: ['[[', ']]'],
    data: {
        host,
        username: sessionStorage.username || localStorage.username,
        user_id: sessionStorage.user_id || localStorage.user_id,
        token: sessionStorage.token || localStorage.token,
        my_data:"",
        my_comments_data:[],
        comments_count:'',
    },

        mounted: function () {
            // this.get_cart();
            this.get_data(),
            this.get_comments_data()

        },
        methods: {
            get_data: function () {

                axios.get(this.host + "/questions/" + get_query_string("pk",1) + "/", {
                    responseType: 'json'
                }

                )
                    .then(response => {
                        // alert('请求成功')
                        this.my_data = response.data
                        // alert(this.my_data.q_text)

                    })
                    .catch(error => {
                        alert('请求失败')
                        console.log(error.response.data);
                    })
            },

            get_comments_data:function () {
                axios.get(this.host + "/comments/" + get_query_string("pk",1) + "/",{
                    responseType:'json'
                    }
                )
                    .then(response => {
                        // alert('评论请求成功')
                        this.my_comments_data = response.data
                        this.comments_count = response.data.length

                        // alert(this.my_comments_data[1].c_text)
                        })
                    .catch(error => {
                        alert('评论请求失败')
                        console.log(error.response.data)
                    })

            },
            add_comments_count:function () {

            }















        }
    }
)

